package br.com.mtg.movethegarbage.framework;

import android.view.MotionEvent;
import android.view.View;

public class GameTouchEvent
{
	public static int TOUCH_DOWN = 0;
	public static int TOUCH_UP = 1;
	public static int TOUCH_DRAGGED = 2;

	public int pointerID;
	public int pointerIndex;
	public int type;
	public float touchX;
	public float touchY;

	public GameTouchEvent(MotionEvent e, View view)
	{
		int action = e.getAction() & MotionEvent.ACTION_MASK;
		switch (action)
		{
			case MotionEvent.ACTION_DOWN:
				this.type = TOUCH_DOWN;
				break;
			case MotionEvent.ACTION_UP:
				this.type = TOUCH_UP;
				break;
			case MotionEvent.ACTION_MOVE:
				this.type = TOUCH_DRAGGED;
				break;
		}
		this.pointerIndex = (e.getAction() & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
		this.pointerID = e.getPointerId(pointerIndex);

		touchX = e.getX(pointerIndex);
		touchY = view.getHeight() - e.getY(pointerIndex);
	}
}
